import java.sql.Array;
import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-05-04
 * Time: 21:28
 */
public class TestDemo {
    ////为了让我们更好的去操作数组，提供了一系列的方法，这些方法在工具类Arrays当中
    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5};
        String ret = Arrays.toString(arr);////将你传进来的数组，以字符串的形式进行输出
        System.out.println(ret);
    }







//for each
    public static void main8(String[] args) {
        int[] arr ={1,2,3,4,5};
        for(int x:arr){
            System.out.print(x+" ");
        }
    }

    public static void main7(String[] args) {
        int[] arr = null;
        System.out.println(arr.length);
    }




    public static void main6(String[] args) {
        int[] arr = {1,2,3,4,5,6,7,8,9,10};
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+" ");
        }
    }



















    public static void func1(int[] array) {
        array = new int[]{1,2,3};
    }
    public static void func2(int[] array) {
        array[0] = 99;
    }

    public static void main4(String[] args) {
        int[] array = {9,8,7};
        func1(array);
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i]+ " ");
            System.out.println();
        }
        System.out.println("===========");
        func2(array);
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i]+ " ");
        }
        System.out.println();
    }










    public static void main2(String[] args) {
        int[] arr1 = new int[3];
        arr1[0] = 10;
        arr1[1] = 20;
        arr1[2] = 30;

        int[] arr2 = new int[]{1,2,3,4,5};
        arr2[0] = 100;
        arr2[1] = 200;

        arr1=arr2;
        arr1[2] = 300;
        arr1[3] = 400;
        arr1[4] = 500;
        for (int i = 0; i < arr2.length; i++) {
            System.out.println(arr2[i]);
        }
    }

















    public static void main1(String[] args) {
        int a = 10;
        int b = 20;
        int[] array = {1,2,3,4,5};
        System.out.println(a);
        System.out.println(b);
        System.out.println("array:"+array);









//        //静态初始化
//        int[] array1 = new int[]{1,2,3,4,5};
//        double[] array2 = new double[]{1.0,2.0,3.0,4.0};
//        String[] array3 = new String[]{"hello","java"};
//        //动态初始化
//        int[] arr1 = new int[5];
//        double[] arr2 = new double[5];
//        String[] arr3 = new String[5];
//
//        //静态
//        int[] array9;
//        array9 = new int[5];
//        //动态
//        int[] array10;
//        array10 = new int[]{1,2,3,4,5};
//        System.out.println("array10:"+array10);

    }
}
